<?php
/**
 *接口所需类
 *
 */
namespace Think;
class Util{

 function hello(){
  echo "hhe";
 }


/**
 验签所需字符串特殊处理函数
*/
function SinParamsToString($params) {
	$sign_str = '';
	// 排序
	ksort($params);
	foreach ($params as $key =>$val){
		if ($key == 'signature'){
			continue;
		}
		$sign_str .= sprintf ( "%s=%s&", $key, $val );
	}
	return substr ( $sign_str, 0, strlen ( $sign_str ) - 1 );
}





/**
最终抛送数据所需字符串特殊处理函数
*/
function arrayToString($params){
	$sign_str = '';
	// 排序
	ksort ( $params );
	foreach ( $params as $key => $val ) {
		
		$sign_str .= sprintf ( "%s=%s&", $key, $val );
	}
	return substr ( $sign_str, 0, strlen ( $sign_str ) - 1 );
		
 }



/**

 抛送数据方法
*/

function postData($url, $data){   
        $ch = curl_init();     
        $timeout = 300;
		curl_setopt($ch,CURLOPT_HTTPHEADER,array(
"content-type: application/x-www-form-urlencoded; 
charset=UTF-8"
));
        curl_setopt($ch, CURLOPT_URL, $url);    
        curl_setopt($ch, CURLOPT_REFERER, "http://localhost");   //站点  
        curl_setopt($ch, CURLOPT_POST, true);     
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);     
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);     
        $handles = curl_exec($ch);     
        curl_close($ch);     
        return $handles;     
    } 





}

?>